#ifndef __COMM_MONITOR_H
#define __COMM_MONITOR_H
#include "allThread.h"
#include <stdint.h>


#define COMM_DEVICE_TABLE \
    X_MACRO(EMS)        /* EMS */ \
    X_MACRO(LC)         /* LC */ \
    X_MACRO(BMS)        /* BMS */ \
    X_MACRO(DCDC)       /* DCDC */ \
    X_MACRO(BIT4)       /*  */\
    X_MACRO(BIT5)       /*  */\
    X_MACRO(BIT6)       /*  */\
    X_MACRO(BIT7)       /*  */\
    X_MACRO(HMI)        /* 触摸屏 */ \
    X_MACRO(ISO_BOARD)  /* 绝缘板 */\
    X_MACRO(FAN1)       /* 风机1 */\
    X_MACRO(FAN2)       /* 风机2 */\
    X_MACRO(METER)      /* 电表 */\
    X_MACRO(BIT13)      /*  */\
    X_MACRO(BIT14)      /*  */\
    X_MACRO(BIT15)      /*  */\
    X_MACRO(QTY)        /*  */\

typedef enum
{
#define X_MACRO(a) COMM_DEVICE_##a,
    COMM_DEVICE_TABLE
#undef X_MACRO    
} commDevice_t;


typedef enum 
{
    COMM_STATE_OFFLINE  = -1,   /* 离线 */
    COMM_STATE_INIT     = 0,    /* 初始 */
    COMM_STATE_ONLINE   = 1,    /* 在线 */
} commState_t;


typedef enum 
{
    COMM_MONITOR_DISABLE    = 0,
    COMM_MONITOR_ENABLE     = 1,
} commMonitorEn_t;


int CommMonitor_AddHeartbeat(commDevice_t dev);
int CommMonitor_GetCommState(commDevice_t dev, commState_t *pState);
int CommMonitor_SetMonitorSwitch(commDevice_t dev, commMonitorEn_t en);
int CommMonitor_ConfigTime(commDevice_t dev, uint32_t timeToOnline, uint32_t timeToOffline);
void CommMonitor_Thread(void *pParam);
int CommMonitor_SendMessage(void);
int CommMonitor_DeleteTimer(void);
int CommMonitor_GetTimerId(void);


#endif
